package IntelSpam::Score;

use 1.0;

use strict;
use warnings;

our $VERSION = '1.0';
our $DEBUG = 1;

our $cfg = {};

our $testcount = 0;
our $cscore = 0;
our $teststring = "";
our $total_weight = 0;

sub new ($) {
	bless {}, shift;
}

sub insert($$$$)
{
	my ($this, $testname, $weight, $score) = @_;
	if($weight == 0){
		return 0;
	}
	if(index($teststring, $testname) == -1){
		$teststring .= ":$testname";
		$testcount++;
	}
	
	$cscore += $score * $weight;
	$total_weight += $weight;
	score();
}

sub score()
{
	return 0 if $total_weight == 0;
	$cscore / $total_weight;
}
sub tests()
{
	return "no_test" if $teststring eq '';
	$teststring;
}


1;
